package com.unis.datapush.controller;

import com.unis.datapush.service.paxy.SafeSchoolService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@Api(tags = {"SafeSchoolController"},value = "平安校园",description = "平安校园相关接口说明")
public class SafeSchoolController {

    private static final Logger log = LoggerFactory.getLogger(SafeSchoolController.class);

    @Autowired
    private SafeSchoolService schoolService;


    @PostMapping("/paxy/violentCrimeMsg")
    @ApiOperation(value = "严重暴力犯罪前科人员预警")
    public Map<String,Object> getViolentCrimeMsg(){
        Map<String,Object> res = new HashMap<String, Object>();
        try {
            List<Map<String,Object>> re = schoolService.getViolentCrimeMsg();
            res.put("code","0");
            res.put("data",re);
            res.put("msg","预警信息获取成功");
        }catch (Exception e){
            e.printStackTrace();
            log.error("严重暴力犯罪前科人员预警异常信息======"+e.getMessage());
            res.put("code","500");
            res.put("data",null);
            res.put("msg","预警信息获取失败");
        }
        return res;
    }

    @PostMapping("/paxy/extremeViolenceMsg")
    @ApiOperation(value = "个人极端暴力重点人口预警")
    public Map<String,Object> getExtremeViolenceMsg(){
        Map<String,Object> resv = new HashMap<String, Object>();
        try {
            List<Map<String,Object>> rev = schoolService.getExtremeViolenceMsg();
            resv.put("code","500");
            resv.put("data",rev);
            resv.put("msg","预警信息获取失败");
        }catch (Exception e){
            e.printStackTrace();
            log.error("个人极端暴力重点人口预警异常信息======"+e.getMessage());
            resv.put("code","500");
            resv.put("data",null);
            resv.put("msg","预警信息获取失败");
        }
        return resv;
    }

}
